package com.tedu.api;

import org.junit.Test;

/**
 * 1.输出字符串"HelloJava"的字符串长度
 * 2.输出"HelloJava"中o的位置
 * 3.输出"HelloJava"中下标为5处开始第一次出现以"o"的位置
 * 4.截取"HelloJava"中"Hello"并输出
 * 5.截取"HelloJava"中"Java"并输出
 * 6.将字符串" Hello "中两边的空白去掉后输出
 * 7.输出"HelloJava"中第6个字符"J"
 * 8.将"HelloJava"转换为小写，然后转换为大写
 */
public class 作业 {
    // 1.
    @Test
    public void testLength() {
        String str = "HelloJava";//9
        System.out.println(str.length());
    }

    //2.
    @Test
    public void indexOf() {
        String str = "HelloJava";
        int index = str.indexOf("o");
        System.out.println(str.indexOf("o"));
    }

    //3.
    @Test
    public void IndexOf() {
        String str = "HelloJava";
        int position = str.indexOf("o", 5);
        System.out.println("从下标 5 开始，字符 'o' 首次出现的位置为：" + position);
    }

    //4.
    @Test
    public void subString() {
        String url = "HelloJava";
        url = url.substring(0, 5);
        System.out.println(url);
    }

    //5
    @Test
    public void subString1() {
        String url = "HelloJava";
        url = url.substring(5, 9);
        System.out.println(url);
    }

    //6
    @Test
    public void testTrim() {
        String str = " Hello ";
        System.out.println("去掉空格" + str);
    }

    //7.
    @Test
    public void charAt() {
        String str = "HelloJava";
        char c = str.charAt(5);
        System.out.println(c);
    }

    //8.
    @Test
    public void toUpperCase() {
        String str = "HelloJava";
        str = str.toUpperCase();
        System.out.println(str);
    }
    @Test
    public void toLowerCase() {
        String str = "HelloJava";
        str = str.toLowerCase();
        System.out.println(str);
    }
}